﻿<Serializable()> Public MustInherit Class ShapeLayer
    Inherits Layer

    Public Sub New(ByVal ln As String, ByVal tl As BaseTool)
        MyBase.new(ln, "")

    End Sub

    '这些都是为了讨厌的VB事件逻辑啊
    Protected Sub New( _
      ByVal info As System.Runtime.Serialization.SerializationInfo, _
      ByVal context As System.Runtime.Serialization.StreamingContext)

        MyBase.New(info, context)

    End Sub


    Public Overrides Sub Dispose()

    End Sub

    Protected Overrides Sub DrawText()

    End Sub

    Public Overrides Sub InitLayer(ByRef m As AxMapWinGIS.AxMap)

    End Sub

    Public Overrides Sub InitNewLayer(ByRef m As AxMapWinGIS.AxMap, ByVal OutPath As String)

    End Sub

    Public Overrides Sub ReLoad(ByRef m As AxMapWinGIS.AxMap, ByVal fPath As String)

    End Sub

    '保存和加载
    Public Overrides Sub Save()

        Dim sf As MapWinGIS.Shapefile = mapwin.get_GetObject(m_iLayer)
        Dim bS As Boolean = sf.Save()
        If bS Then
            System.Windows.Forms.MessageBox.Show("文件保存错误，请查看相应权限!")

        End If

    End Sub

    Public Overrides Sub SaveAs(ByVal strPath As String)

        Dim fn As String = strPath + lname + ".shp"

        Dim myPath(2) As String
        myPath(0) = strPath + lname + ".shp"
        myPath(1) = strPath + lname + ".dbf"
        myPath(2) = strPath + lname + ".shx"


        For i As Integer = 0 To myPath.Length - 1
            If System.IO.File.Exists(myPath(i)) Then
                Try
                    System.IO.File.SetAttributes(myPath(i), IO.FileAttributes.Normal)
                    System.IO.File.Delete(myPath(i))
                Catch ex As Exception

                End Try

            End If
        Next

        Dim sf As MapWinGIS.Shapefile = mapwin.get_GetObject(m_iLayer)

        Dim bS As Boolean = sf.SaveAs(fn)

        If bS Then
            System.Windows.Forms.MessageBox.Show("文件保存错误，请查看相应权限!")

        End If


    End Sub



    Public Overrides Sub InitProp()

    End Sub
End Class
